﻿CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(NFMMOSnsCommon)

AUX_SOURCE_DIRECTORY(./ SRC)

if (CMAKE_BUILD_TYPE STREQUAL "Release")

    ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRC})
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")

    ADD_LIBRARY(${PROJECT_NAME} STATIC ${SRC})
elseif (CMAKE_BUILD_TYPE STREQUAL "DynamicRelease")

    ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRC})
    TARGET_LINK_LIBRARIES(${PROJECT_NAME} NFServerMessage NFServerCommon NFMMOLogicMessage NFMMOLogicCommon NFMMOResStore NFGameCommon)
elseif (CMAKE_BUILD_TYPE STREQUAL "DynamicDebug")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")

    ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRC})
    TARGET_LINK_LIBRARIES(${PROJECT_NAME} NFServerMessage NFServerCommon NFMMOLogicMessage NFMMOLogicCommon NFMMOResStore NFGameCommon)
endif ()

# ============================================================================
# Install 配置
# ============================================================================
# 只有动态库版本才需要安装
if (CMAKE_BUILD_TYPE STREQUAL "DynamicRelease")
    install(TARGETS ${PROJECT_NAME}
            LIBRARY DESTINATION "Bin/DynamicRelease"
            RUNTIME DESTINATION "Bin/DynamicRelease"
            ARCHIVE DESTINATION "Bin/DynamicRelease")
elseif(CMAKE_BUILD_TYPE STREQUAL "DynamicDebug")
    install(TARGETS ${PROJECT_NAME}
            LIBRARY DESTINATION "Bin/DynamicDebug"
            RUNTIME DESTINATION "Bin/DynamicDebug"
            ARCHIVE DESTINATION "Bin/DynamicDebug")
endif()

